package com.ljcalc.business.components.requests;

import java.io.File;

/**
 * INteger Random Request from Random.org
 * @author SELuoc
 *
 */
public class IntegerUserRequest extends HTTPUserRequest {

	private final static String RANDOM_ORG_INTEGER = "http://www.random.org";
	
	private final static String INTEGERS = "integers";
	
	private final static String NUM = "num";
	private final static String MIN = "min";
	private final static String MAX = "max";
	private final static String COL = "col";
	private final static String BASE = "base";
	private final static String FORMAT = "format";
	private final static String RND = "rnd";
	
	public final static String FORMAT_HTML = "html";
	public final static String FORMAT_PLAIN = "plain";
	
	public final static String RND_NEW = "new";
	public final static String RND_ID = "id.identifier";
	public final static String RND_DATE = "date.iso-date";
	
	private long num = 0;
	private	long min = 0;
	private long max = 0;
	private long col = 0;
	private int base = 10; //decimal
	private String format = FORMAT_PLAIN;
	private String rnd = RND_NEW;
	
	
	
	public IntegerUserRequest(long min,long max){
		this(100,min,max);
	}
	
	public IntegerUserRequest(long num, long min,long max){
		this(num,min,max,RND_NEW);
	}
	
	public IntegerUserRequest(long num, long min,long max, String rnd){
		this(num,min,max, 10, rnd);
	}
	
	public IntegerUserRequest(long num, long min,long max, int base, String rnd){
		this(num,min,max,1,base,FORMAT_PLAIN, rnd);
	}
	
	public IntegerUserRequest(long num, long min, long max, long col, int base, String format, String rnd){
		super(RANDOM_ORG_INTEGER);
		this.num = num;
		this.min = min;
		this.max = max;
		this.col = col;
		this.base = base;
		this.format = format;
		this.rnd = rnd;		
	}
	
	/**
	 * example
	 * http://www.random.org/integers/?num=10&min=1&max=6&col=1&base=10&format=plain&rnd=new
	 * @return
	 */
	public String getURLStr(){
		return url + SLASH + INTEGERS + SLASH + QUESTION_MARK
			+ NUM + EQUAL_SIGN + this.num + AMPERSAND
			+ MIN + EQUAL_SIGN + this.min + AMPERSAND
			+ MAX + EQUAL_SIGN + this.max + AMPERSAND
			+ COL + EQUAL_SIGN + this.col + AMPERSAND
			+ BASE + EQUAL_SIGN + this.base + AMPERSAND
			+ FORMAT + EQUAL_SIGN + this.format + AMPERSAND
			+ RND + EQUAL_SIGN + this.rnd;
	} 
	
}
